package com.ky.pro.java.fx.spring.boot.app;

import com.ky.pro.java.fx.spring.entity.School;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

@SpringBootApplication
public class SpringBootDemoAppApplication implements ApplicationContextAware {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootDemoAppApplication.class, args);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        List<School> schools = (List<School>) applicationContext.getBean("schools");
        schools.forEach(school -> {
            System.out.println();
            System.out.println("school no." + school.getId() + ": ");
            school.dump();
            System.out.println();
        });
    }
}
